<template>
  <div class="app-container">
    <div class="filter">
      <el-form :inline="true" class="filter-container">
        <el-form-item label="日期">
          <el-date-picker
            v-model="query.transDate"
            type="date"
            placeholder="选择日期"
            value-format="yyyy-MM-dd">
          </el-date-picker>
        </el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          title="搜索"
          @click="search">
        </el-button>
        <!-- <el-button type="primary" size="medium" @click="search">查询</el-button> -->
      </el-form>
      <div class="fr clearfix buttonBox new-refrech">
        <el-button
            class="btn-size fl"
            icon="el-icon-refresh"
            title="刷新"
            @click="refresh">
        </el-button>
      </div>
    </div>
    <el-table
      :data="tableData" stripe  
      style="width: 100%" v-loading="loading" class="table-out-border">
      <el-table-column
        prop="transDate"
        label="日期">
      </el-table-column>
      <!-- <el-table-column
        prop="realPayAmt"
        label="金钱">
        <template slot-scope="scope">
          {{scope.row.realPayAmt|moneyFormatter}}
        </template>
      </el-table-column> -->

      <el-table-column
        label="操作">
        <template slot-scope="scope">
          <el-button type="text" @click="downLoad(scope.row.transDate)">下载</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- <el-table
      :data="tableData" stripe  
      style="width: 100%" v-loading="loading" class="table-out-border">
      <el-table-column
        type="expand">
        <template slot-scope="props">
          <el-table :data="props.data">
            <el-table-column ></el-table-column>
          </el-table>
        </template>
      </el-table-column>
      <el-table-column
        prop="realPayAmt"
        label="金钱">
        <template slot-scope="scope">
          {{scope.row.realPayAmt|moneyFormatter}}==
          {{2333|moneyFormatter}}
        </template>
      </el-table-column>

      <el-table-column
        label="操作">
        <template slot-scope="scope">
          <el-button @click="downLoad(scope.row.transDate)">下载</el-button>
        </template>
      </el-table-column>
    </el-table> -->
    <div class="pagination-container pull-right">
      <el-pagination 
        @size-change="handleSizeChange" 
        @current-change="handleCurrentChange" 
        :current-page="query.page" 
        :page-size="query.pageSize" 
        :total="totalCount" 
        layout="total, sizes, prev, pager, next, jumper" 
        :page-sizes="[10, 20, 30, 40]">
      </el-pagination>
    </div>
   </div>

</template>

<script>
import { mapGetters } from 'vuex'
import { listBalanceExcel } from '@/api/errorManage'
export default {
  data() {
    return {
      loading: true,
      listData: [],
      query: {
        transDate: '',
        page: 1,
        pageSize: 10
      },
      totalCount: null,
      editFlag: false,
      tableData: [],
      temp: {
        loanRateTypeArr: [{
          label: '全部',
          value: ''
        }, {
          label: '年利率',
          value: 'Y'
        }, {
          label: '日利率',
          value: 'D'
        }],
        fGetList: true
      },
      multipleSelection: []
    }
  },
  computed: {
    ...mapGetters([
      'token'
    ])
  },
  filters: {
    isOpenFilter(item) {
      const itemMap = {
        '1': '开启',
        '0': '关闭'
      }
      return itemMap[item]
    }
  },
  created() {
    this.getData()
  },
  methods: {
    getData() {
      listBalanceExcel({}, this.query).then(res => {
        this.loading = false
        this.handleData(res.data)
      }).catch(error => {
        this.loading = false
        console.log('error=' + error)
      })
    },
    handleData(resdata) {
      this.tableData = resdata.data
      this.totalCount = resdata.recordsTotal
    },
    editForm() {
      this.editFlag = true
    },
    // 修改每页条数
    handleSizeChange(val) {
      this.query.pageSize = val
      this.getData()
    },
    // 切换页面
    handleCurrentChange(val) {
      this.query.page = val
      this.getData()
    },
    search() {
      this.query.page = 1
      this.getData()
    },
    refresh() { // 刷新按钮点击事件
      this.query.page = 1
      this.getData()
    },
    downLoad(id) {
      const url = '/api/allinpay.transfer.bill/pay/bill/uploadExcel?transDate=' + id + '&token=' + this.token
      window.open(url)
    }
  }
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.el-form-item{
  margin-bottom: 10px;
  .el-form-item{
    margin-bottom:0
  }
  label{
    width:50%;
  }
}
.title{
  font-size: 22px;
}
.btn-rows {
  text-align: center;
  padding-top:20px;
  .el-button{
    
  }
}
</style>


